<template>
    <div class="action action-hide">
        <Button class="action-button" :icon="model.icon" type="primary" @click="actionTrigger">
            {{model.name}}
        </Button>
        <div class="action-modal-box">
            <Import-modal :paramId="paramId" :modalShow="modalShow" :open.sync="modalShow"></Import-modal>
        </div>
    </div>
</template>
<script>
import modalActionBase from '../modalActionBase'
import ImportModal from './modal'
import $ from '@/common'


export default {
    name: 'actionImport',
    extends: modalActionBase,
    data() {
        return {
            paramId: null,
            pathSubmit: '/service/{app}/excel/ds'
        }
    },
    methods: {
        actionTrigger(id, data, index) {
            this.paramId = id;
            if (data) { this.actionData = data }
            if (!this.isLoad) this.isLoad = true
            this.$nextTick(() => {
                this.modalShow = true
            })
        },
        actionSubmit(data) {
            $.link(this.pathSubmit, data, {
                method: 'put'
            }).then((res) => {
                this.$owner.update()
                this.actionCancel()
            })
        }
    },
    created() {
    },
    components: {
        ImportModal
    }
}
</script>
